# -*- coding: utf-8 -*-

import sys
from PyQt5 import QtWidgets
from PyQt5.QtCore import QCoreApplication
from PyQt5.QtWidgets import QDialog, QMessageBox

from uiview.login_ui import Ui_Dialog as LoginUI
from window.main import MainWin

class LoginWin(LoginUI, QDialog):
    def __init__(self):
        super(LoginWin, self).__init__()
        self.setupUi(self)
        self.loginBtn.clicked.connect(self.login_system)
        self.closeBtn.clicked.connect(QCoreApplication.instance().quit)
        self.main_ui = MainWin()

    def login_system(self):
        if self.userName.text() != "admin":
            QMessageBox.about(self, "系统提示", "您输入的账号有误,请检查后登陆.")
        elif self.userPass.text() != "123123":
            QMessageBox.about(self, "系统提示", "您输入密码有误,请检查输入的密码是否正确")
        else:
            self.main_ui.show()
            self.close()

if __name__ == '__main__':
    app = QtWidgets.QApplication(sys.argv)
    main = LoginWin()
    main.show()
    sys.exit(app.exec_())
